//
//  DSSHMeInfoVC.m
//  DSSH
//
//  Created by lcy on 16/4/1.
//  Copyright © 2016年 lcy. All rights reserved.
//

#import "DSSHMeInfoVC.h"
#import "DSSHMeBlackRecordVC.h"
@interface DSSHMeInfoVC ()<UITableViewDataSource,UITableViewDelegate>
@property(nonatomic,strong)UITableView* myInfoTableView;
@end

@implementation DSSHMeInfoVC

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupViewAndData];
    // Do any additional setup after loading the view.
}
-(void)setupViewAndData
{
    self.title = @"我的账号";
    self.view.backgroundColor = [UIColor whiteColor];
    self.myInfoTableView = [[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStyleGrouped];
    self.myInfoTableView.delegate = self;
    self.myInfoTableView.dataSource = self;
    self.myInfoTableView.tableFooterView = [[UIView alloc]init];
    [self.view addSubview:self.myInfoTableView];
    
    UIBarButtonItem * backBarBtn = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"fanhui"] style:UIBarButtonItemStylePlain target:self action:@selector(backBarBtnClick)];
    self.navigationItem.leftBarButtonItem = backBarBtn;
}
-(void)backBarBtnClick
{
    [self.navigationController popViewControllerAnimated:YES];
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 2;
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell * cell = [tableView cellForRowAtIndexPath:indexPath];
    if (!cell)
    {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cellID"];
    }
    if (indexPath.section == 0)
    {
        if (indexPath.row == 0)
        {
            UILabel * titleLabel = [UILabel new];
            titleLabel.text = @"账号";
            titleLabel.frame = CGRectMake(5*WIDTH_SCALE, 7*HIGHT_SCALE, 45*WIDTH_SCALE, 30*HIGHT_SCALE);
            titleLabel.font = FONT(13);
            titleLabel.textAlignment = NSTextAlignmentLeft;
            [cell.contentView addSubview:titleLabel];
            
            UILabel * rightLabel = [UILabel new];
            rightLabel.text = @"182000000";
            rightLabel.textAlignment = NSTextAlignmentRight;
            rightLabel.font = FONT(13);
            rightLabel.textColor = [UIColor grayColor];
            [cell.contentView addSubview:rightLabel];
            [rightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
                make.right.equalTo(cell.contentView).with.offset(-5*WIDTH_SCALE);
                make.top.equalTo(cell.contentView).with.offset(7*HIGHT_SCALE);
                make.left.equalTo(titleLabel.mas_right).with.offset(5*WIDTH_SCALE);
                make.height.mas_equalTo(30*HIGHT_SCALE);
            }];
            
        }
        if (indexPath.row == 1)
        {
            UILabel * titleLabel = [UILabel new];
            titleLabel.text = @"会员级别";
            titleLabel.font = FONT(13);
            titleLabel.textAlignment = NSTextAlignmentLeft;
            [cell.contentView addSubview:titleLabel];
            
            UILabel * degreeLabel = [UILabel new];
            degreeLabel.text = @"普通会员";
            degreeLabel.textAlignment = NSTextAlignmentLeft;
            degreeLabel.font = FONT(13);
            degreeLabel.textColor = [UIColor grayColor];
            [cell.contentView addSubview:degreeLabel];
            
            UIButton * gradeBtn = [UIButton new];
            [gradeBtn setTitle:@"升级" forState:UIControlStateNormal];
            [gradeBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
            gradeBtn.titleLabel.font = FONT(13);
            [gradeBtn setBackgroundColor:RGBA(164, 221, 255, 1)];
            [gradeBtn addTarget:self action:@selector(clickGradeBtn) forControlEvents:UIControlEventTouchUpInside];
            [cell.contentView addSubview:gradeBtn];
            
            [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(cell.contentView).with.offset(7*HIGHT_SCALE);
                make.width.mas_equalTo(65*WIDTH_SCALE);
                make.left.equalTo(cell.contentView.mas_left).with.offset(5*WIDTH_SCALE);
                make.height.mas_equalTo(30*HIGHT_SCALE);
            }];
            [gradeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
                make.right.equalTo(cell.contentView.mas_right).with.offset(-5*WIDTH_SCALE);
                make.top.equalTo(cell.contentView).with.offset(7*HIGHT_SCALE);
                make.width.mas_equalTo(50*WIDTH_SCALE);
                make.height.mas_equalTo(30*HIGHT_SCALE);
                
            }];
            [degreeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
                make.right.equalTo(gradeBtn.mas_left).with.offset(10*WIDTH_SCALE);
                make.top.equalTo(cell.contentView).with.offset(7*HIGHT_SCALE);
                make.left.equalTo(titleLabel.mas_right).with.offset(5*WIDTH_SCALE);
                make.height.mas_equalTo(30*HIGHT_SCALE);
            }];

        }
        
    }
    if (indexPath.section == 1)
    {
        if (indexPath.row == 0)
        {
            UILabel * titleLabel = [UILabel new];
            titleLabel.text = @"账号黑点";
            titleLabel.font = FONT(13);
            titleLabel.textAlignment = NSTextAlignmentLeft;
            [cell.contentView addSubview:titleLabel];
            
            
            UILabel * detailsLabel = [UILabel new];
            detailsLabel.text = @"黑点明细";
            detailsLabel.textAlignment = NSTextAlignmentRight;
            detailsLabel.font = FONT(13);
            detailsLabel.textColor = [UIColor grayColor];
            [cell.contentView addSubview:detailsLabel];
            
            [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(cell.contentView).with.offset(7*HIGHT_SCALE);
                make.width.mas_equalTo(65*WIDTH_SCALE);
                make.left.equalTo(cell.contentView.mas_left).with.offset(5*WIDTH_SCALE);
                make.height.mas_equalTo(30*HIGHT_SCALE);
            }];
            [detailsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
                make.right.equalTo(cell.contentView.mas_right).with.offset(10*WIDTH_SCALE);
                make.top.equalTo(cell.contentView).with.offset(7*HIGHT_SCALE);
                make.width.mas_equalTo(65*WIDTH_SCALE);
                make.height.mas_equalTo(30*HIGHT_SCALE);
            }];
            
            for (int i = 0; i<4; i++)
            {
                UIImageView* imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"heidian"]];
                imageView.frame = CGRectMake(75*WIDTH_SCALE+(10+3)*WIDTH_SCALE*i, 17*HIGHT_SCALE, 10*WIDTH_SCALE, 10*HIGHT_SCALE);
                [cell.contentView addSubview:imageView];
            }
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        }else
        {
            UILabel * titleLabel = [UILabel new];
            titleLabel.text = @"已进入黑名单";
            titleLabel.font = FONT(13);
            titleLabel.textColor = [UIColor grayColor];
            titleLabel.textAlignment = NSTextAlignmentLeft;
            [cell.contentView addSubview:titleLabel];
            
            UIButton * submitBtn = [UIButton new];
            [submitBtn setTitle:@"申请解除" forState:UIControlStateNormal];
            [submitBtn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
            submitBtn.titleLabel.font = FONT(13);
            [submitBtn addTarget:self action:@selector(clickSubmitBtn) forControlEvents:UIControlEventTouchUpInside];
            [cell.contentView addSubview:submitBtn];
            
            [submitBtn mas_makeConstraints:^(MASConstraintMaker *make) {
                make.right.equalTo(cell.contentView.mas_right).with.offset(-5*WIDTH_SCALE);
                make.top.equalTo(cell.contentView).with.offset(7*HIGHT_SCALE);
                make.width.mas_equalTo(70*WIDTH_SCALE);
                make.height.mas_equalTo(30*HIGHT_SCALE);
                
            }];
            [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(cell.contentView).with.offset(7*HIGHT_SCALE);
                make.right.equalTo(submitBtn.mas_left).with.offset(-10*WIDTH_SCALE);
                make.left.equalTo(cell.contentView.mas_left).with.offset(10*WIDTH_SCALE);
                make.height.mas_equalTo(30*HIGHT_SCALE);
            }];
        }

    }
    return cell;
}
-(void)clickGradeBtn
{
    
}
-(void)clickSubmitBtn
{
    
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 3*HIGHT_SCALE;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 0.0001*HIGHT_SCALE;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if (indexPath.section == 1)
    {
        if (indexPath.row == 0)
        {
            DSSHMeBlackRecordVC * vc = [[DSSHMeBlackRecordVC alloc]init];
            [self.navigationController pushViewController:vc animated:YES];
        }
    }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
